<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="quo" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/psi/supplychainmana/AmendmentContract?'+vueparams+'')" type='success' size="mini"><i class='fa fa-edit'></i>修改</el-button>
          <el-button @click="gotoPage('/psi/supplychainmana/ProcurementContractS?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
          <el-button @click="c_pirce('')" type='success' size="mini"><i class='fa fa-check'></i>合同确定</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 合同管理 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="合同编号" prop="quo_num">
                  {{quo.quo_num}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="合同主题" prop="">
                  {{quo.quo_theme}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="供应商" prop="">
                  {{quo.quo_client}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人" prop="">
                  {{quo.quo_contact}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="供应商地址" prop="">
                  <div style="white-space: pre-wrap;">{{quo.quo_address}}</div>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="签订日期" prop="quo_pacttime">
                  {{getDateTimeString(quo,'quo_pacttime')}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="失效日期 " prop="">
                  {{getDateTimeString(quo,'quo_faildate')}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="内部备注" prop="">
                  <div style="white-space: pre-wrap;">{{quo.quo_insides}}</div>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 产品列表 </span>
          </div>
          <el-table :data="pum">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_producenum('&CMIDpronum_id='+scope.row.pronum_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popModifyProductSupply('&CMIDpronum_id='+scope.row.pronum_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="产品条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="产品名称" prop="pronum_prodece">
            </el-table-column>
            <el-table-column label="产品型号" prop="product_model">
            </el-table-column>
            <el-table-column label="产品规格" prop="product_norm">
            </el-table-column>
            <el-table-column label="生产厂家" prop="client_name">
            </el-table-column>
            <el-table-column label="简要描述" prop="pronum_remark">
            </el-table-column>
            <el-table-column label="数量" prop="pronum_no">
            </el-table-column>
            <el-table-column label="单价" prop="t_price">
            </el-table-column>
            <el-table-column label="发货时间" prop="pronum_endate">
              <template slot-scope="scope">
                {{getDateTimeString(scope.row,'pronum_endate')}}
              </template>
            </el-table-column>
            <el-table-column label="总价" prop="total_prices">
            </el-table-column>
          </el-table>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="合计" prop="">
                  {{s_num.total_prices}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="popProductSelection('&category_id=')" type='primary' size="mini">选择产品</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 甲乙双方责任 </span>
          </div>
          <el-table :data="s_duty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_duty('&CMIDduty_id='+scope.row.duty_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popUpResponsibility('&CMIDduty_id='+scope.row.duty_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="duty_name">
            </el-table-column>
          </el-table>
          <el-button @click="popResponsibilityChoice('')" type='primary' size="mini">选择责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款方式 </span>
          </div>
          <el-table :data="s_pay">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_pay('&CMIDpay_id='+scope.row.pay_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popPaymentMethodSupps('&CMIDpay_id='+scope.row.pay_id+'')">修改</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="首次付款" prop="pay_first">
            </el-table-column>
            <el-table-column label="二次付款" prop="pay_sec">
            </el-table-column>
            <el-table-column label="尾付款" prop="pay_end">
            </el-table-column>
          </el-table>
          <el-button @click="popPaymentMethodSupp('')" type='primary' size="mini">建立付款方式</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 付款账号 </span>
          </div>
          <el-table :data="s_bank">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popUpIncreaseBankSupply('&CMIDbank_id='+scope.row.bank_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_bank('&CMIDbank_id='+scope.row.bank_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="账户类型" prop="bank_type">
            </el-table-column>
            <el-table-column label="银行名称" prop="bank_tname">
            </el-table-column>
            <el-table-column label="开户姓名" prop="bank_name">
            </el-table-column>
            <el-table-column label="开户账号" prop="bank_account">
            </el-table-column>
          </el-table>
          <el-button @click="popSelectionPaymentSupply('')" type='primary' size="mini">选择付款账号</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 违约责任 </span>
          </div>
          <el-table :data="s_breakduty">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popModifyLiabilityContract('&CMIDbreakduty_id='+scope.row.breakduty_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_breakduty('&CMIDbreakduty_id='+scope.row.breakduty_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="break_name">
            </el-table-column>
          </el-table>
          <el-button @click="popLiabilityContract('')" type='primary' size="mini">选择违约责任</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 其他要求 </span>
          </div>
          <el-table :data="s_demand">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popModifOtherRequire('&CMIDdemand_id='+scope.row.demand_id+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_demand('&CMIDdemand_id='+scope.row.demand_id+'')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="备注" prop="demand_name">
            </el-table-column>
          </el-table>
          <el-button @click="popOtherRequireAdd('')" type='primary' size="mini">选择其他要求</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'采购合同'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="ModifyProductSupplyVisible" append-to-body>
      <ModifyProductSupply v-if="ModifyProductSupplyVisible" ref="ModifyProductSupply" :popparams="popparams"> </ModifyProductSupply>
    </el-dialog>
    <el-dialog :visible.sync="ProductSelectionVisible" append-to-body>
      <ProductSelection v-if="ProductSelectionVisible" ref="ProductSelection" :popparams="popparams"> </ProductSelection>
    </el-dialog>
    <el-dialog :visible.sync="UpResponsibilityVisible" append-to-body>
      <UpResponsibility v-if="UpResponsibilityVisible" ref="UpResponsibility" :popparams="popparams"> </UpResponsibility>
    </el-dialog>
    <el-dialog :visible.sync="ResponsibilityChoiceVisible" append-to-body>
      <ResponsibilityChoice v-if="ResponsibilityChoiceVisible" ref="ResponsibilityChoice" :popparams="popparams"> </ResponsibilityChoice>
    </el-dialog>
    <el-dialog :visible.sync="PaymentMethodSuppsVisible" append-to-body>
      <PaymentMethodSupps v-if="PaymentMethodSuppsVisible" ref="PaymentMethodSupps" :popparams="popparams"> </PaymentMethodSupps>
    </el-dialog>
    <el-dialog :visible.sync="PaymentMethodSuppVisible" append-to-body>
      <PaymentMethodSupp v-if="PaymentMethodSuppVisible" ref="PaymentMethodSupp" :popparams="popparams"> </PaymentMethodSupp>
    </el-dialog>
    <el-dialog :visible.sync="UpIncreaseBankSupplyVisible" append-to-body>
      <UpIncreaseBankSupply v-if="UpIncreaseBankSupplyVisible" ref="UpIncreaseBankSupply" :popparams="popparams"> </UpIncreaseBankSupply>
    </el-dialog>
    <el-dialog :visible.sync="SelectionPaymentSupplyVisible" append-to-body>
      <SelectionPaymentSupply v-if="SelectionPaymentSupplyVisible" ref="SelectionPaymentSupply" :popparams="popparams"> </SelectionPaymentSupply>
    </el-dialog>
    <el-dialog :visible.sync="ModifyLiabilityContractVisible" append-to-body>
      <ModifyLiabilityContract v-if="ModifyLiabilityContractVisible" ref="ModifyLiabilityContract" :popparams="popparams"> </ModifyLiabilityContract>
    </el-dialog>
    <el-dialog :visible.sync="LiabilityContractVisible" append-to-body>
      <LiabilityContract v-if="LiabilityContractVisible" ref="LiabilityContract" :popparams="popparams"> </LiabilityContract>
    </el-dialog>
    <el-dialog :visible.sync="ModifOtherRequireVisible" append-to-body>
      <ModifOtherRequire v-if="ModifOtherRequireVisible" ref="ModifOtherRequire" :popparams="popparams"> </ModifOtherRequire>
    </el-dialog>
    <el-dialog :visible.sync="OtherRequireAddVisible" append-to-body>
      <OtherRequireAdd v-if="OtherRequireAddVisible" ref="OtherRequireAdd" :popparams="popparams"> </OtherRequireAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ModifyProductSupply from "@/views/psi/supplychainmana/ModifyProductSupply";
  import ProductSelection from "@/views/psi/supplychainmana/ProductSelection";
  import UpResponsibility from "@/views/psi/supplychainmana/UpResponsibility";
  import ResponsibilityChoice from "@/views/psi/supplychainmana/ResponsibilityChoice";
  import PaymentMethodSupps from "@/views/psi/supplychainmana/PaymentMethodSupps";
  import PaymentMethodSupp from "@/views/psi/supplychainmana/PaymentMethodSupp";
  import UpIncreaseBankSupply from "@/views/psi/supplychainmana/UpIncreaseBankSupply";
  import SelectionPaymentSupply from "@/views/psi/supplychainmana/SelectionPaymentSupply";
  import ModifyLiabilityContract from "@/views/psi/supplychainmana/ModifyLiabilityContract";
  import LiabilityContract from "@/views/psi/supplychainmana/LiabilityContract";
  import ModifOtherRequire from "@/views/psi/supplychainmana/ModifOtherRequire";
  import OtherRequireAdd from "@/views/psi/supplychainmana/OtherRequireAdd";
  export default {
    name: 'ContractManagement',
    components: {
      ModifyProductSupply,
      ProductSelection,
      UpResponsibility,
      ResponsibilityChoice,
      PaymentMethodSupps,
      PaymentMethodSupp,
      UpIncreaseBankSupply,
      SelectionPaymentSupply,
      ModifyLiabilityContract,
      LiabilityContract,
      ModifOtherRequire,
      OtherRequireAdd,
    },
    props: ['popparams'],
    data() {
      return {
        ModifyProductSupplyVisible: false,
        ModifyProductSupplyValue: null,
        ModifyProductSupplyDesc: null,
        ProductSelectionVisible: false,
        ProductSelectionValue: null,
        ProductSelectionDesc: null,
        UpResponsibilityVisible: false,
        UpResponsibilityValue: null,
        UpResponsibilityDesc: null,
        ResponsibilityChoiceVisible: false,
        ResponsibilityChoiceValue: null,
        ResponsibilityChoiceDesc: null,
        PaymentMethodSuppsVisible: false,
        PaymentMethodSuppsValue: null,
        PaymentMethodSuppsDesc: null,
        PaymentMethodSuppVisible: false,
        PaymentMethodSuppValue: null,
        PaymentMethodSuppDesc: null,
        UpIncreaseBankSupplyVisible: false,
        UpIncreaseBankSupplyValue: null,
        UpIncreaseBankSupplyDesc: null,
        SelectionPaymentSupplyVisible: false,
        SelectionPaymentSupplyValue: null,
        SelectionPaymentSupplyDesc: null,
        ModifyLiabilityContractVisible: false,
        ModifyLiabilityContractValue: null,
        ModifyLiabilityContractDesc: null,
        LiabilityContractVisible: false,
        LiabilityContractValue: null,
        LiabilityContractDesc: null,
        ModifOtherRequireVisible: false,
        ModifOtherRequireValue: null,
        ModifOtherRequireDesc: null,
        OtherRequireAddVisible: false,
        OtherRequireAddValue: null,
        OtherRequireAddDesc: null,
        vueparams: this.getVUEParams(""),
        quo: {
          quo_num: null,
          quo_theme: null,
          quo_client: null,
          quo_contact: null,
          quo_address: null,
          quo_pacttime: null,
          quo_faildate: null,
          quo_insides: null,
        },
        pum: [],
        s_num: {
          total_prices: null,
        },
        s_duty: [],
        s_pay: [],
        s_bank: [],
        s_breakduty: [],
        s_demand: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "821959E4C08E497BA9C4B10D9571712F",
        name: "采购任务右菜单",
        selected: "采购合同"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/contractManagement?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_producenum(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_producenum?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_bank(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_bank?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_duty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_duty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_pay(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_pay?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_breakduty(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_breakduty?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      d_demand(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/d_demand?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      c_pirce(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/ProcureSupplyAction/c_pirce?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/supplychainmana/ProcurementContractS/procurementContractS?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popModifyProductSupply(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyProductSupplyVisible = !this.ModifyProductSupplyVisible;
      },
      popProductSelection(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ProductSelectionVisible = !this.ProductSelectionVisible;
      },
      popUpResponsibility(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UpResponsibilityVisible = !this.UpResponsibilityVisible;
      },
      popResponsibilityChoice(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ResponsibilityChoiceVisible = !this.ResponsibilityChoiceVisible;
      },
      popPaymentMethodSupps(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PaymentMethodSuppsVisible = !this.PaymentMethodSuppsVisible;
      },
      popPaymentMethodSupp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.PaymentMethodSuppVisible = !this.PaymentMethodSuppVisible;
      },
      popUpIncreaseBankSupply(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.UpIncreaseBankSupplyVisible = !this.UpIncreaseBankSupplyVisible;
      },
      popSelectionPaymentSupply(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SelectionPaymentSupplyVisible = !this.SelectionPaymentSupplyVisible;
      },
      popModifyLiabilityContract(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyLiabilityContractVisible = !this.ModifyLiabilityContractVisible;
      },
      popLiabilityContract(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.LiabilityContractVisible = !this.LiabilityContractVisible;
      },
      popModifOtherRequire(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifOtherRequireVisible = !this.ModifOtherRequireVisible;
      },
      popOtherRequireAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.OtherRequireAddVisible = !this.OtherRequireAddVisible;
      },
    },
  }
</script>
